<template>
	<view>
		<navbar :isback="true" :title="title"></navbar>
		<u-sticky bgColor="#fff" v-if="poplist.length>0" customNavHeight="44">
			<view class="tab">
				<u-tabs :list="poplist" lineWidth="118rpx" lineHeight='10rpx' lineColor="#0381FC" :activeStyle="{
				            color: '#1E1E1E',
				            fontWeight: 'bold',
				            transform: 'scale(1.15)'
				        }" :inactiveStyle="{
				            color: '#1E1E1E',
				            transform: 'scale(1)'
				        }" itemStyle="padding-left: 35rpx; padding-right: 35rpx; height: 50rpx;font-size:26rpx;" @click="clicktab">
				</u-tabs>
			</view>
		</u-sticky>
		<u-loading-page icon-size="100rpx" :loading="loading" loading-text="驼乡生活信息超市"></u-loading-page>
		<view class="" v-if="!loading">
			<view class="" v-if="msglist.length>0">
				<auditingitem :item="item" :status='item.status' v-for="(item,index) in msglist" :key="index" @refuse='refuse(item)' @adopt='adopt(item)'></auditingitem>
			</view>
			<view class="" v-else style="padding-top: 50rpx;">
				<u-empty mode="list" text="暂无审核信息">
				</u-empty>
			</view>
		</view>
		
		<!-- 拒绝弹框 -->
		<u-popup mode="center" :show="show" round="30rpx" @close="show=false" bgColor='transparent'>
			<view class="popbox">
				<view class="popbox__title">
					<text class="popbox__title__xing">*</text>拒绝原因<text class="popbox__title__xing">*</text>
				</view>
				<u-textarea v-model="value1" placeholder="请输入拒绝理由" height='210rpx' :placeholderStyle='{color:"#5C5C5C",fontSize:"24rpx",}' border='none'></u-textarea>
				<view class="popbox__footer">
					<u-button @click="submit" text="确认" color="linear-gradient(156deg, #0484FC, #5D77FC)" size="large" :customStyle="{height:'93rpx'}" shape='circle'></u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import home from '@/api/_home.js'
	import { BASE_URL } from '@/api/config';
	export default {
		data() {
			return {
				title:'',
				value1:'',
				poplist:[
					{name:'置顶发布',type:2},
					{name:'普通发布',short_type:1,type:1},
					{name:'优惠发布',short_type:2,type:1},
					{name:'其他发布',type:3},
				],
				loading:true,
				status:0,
				msglist: [],
				show:false,
				type:2,
				short_type:'',
				id:'',
				statusArr:''
			};
		},
		onLoad(o) {
			this.title=o.title
			this.status=o.status
			
		},
		onShow() {
			if(this.status==2){
				this.status=''
				this.statusArr='2,4'
			}
			this.getlist(2)
		},
		methods:{
			refuse(item){//拒绝
				console.log('拒绝',item)
				this.id=item.id
				this.show=true
			},
			submit(){
				if(!this.value1){
					uni.$u.toast('请输入拒绝理由')
					return
				}
				home.changeStatus({status:4,id:this.id,remark:this.value1}).then(res=>{
					if(res.data.code==1){
						this.show=false
						this.getlist()
					}
				})
			},
			adopt(item){//通过
				home.changeStatus({status:2,id:item.id}).then(res=>{
					if(res.data.code==1){
						this.getlist()
					}
				})
			},
			getlist(){
				home.infoList({type:this.type,short_type:this.short_type,status:this.status,statusArr:this.statusArr}).then(res=>{
					if(res.data.code==1){
						this.loading=false
						this.msglist=res.data.data
						this.msglist.map(t=>{
							t.imags=[]
							t.imag=t.ad_images.split(',')
							if(t.imag[0]==''){
								t.imag=[]
							}
							t.imag.map(t1=>{
								t.imags.push(BASE_URL+t1)
							})
							if(t.card_images){
								t.card_images.split(',').map(t1=>{
									t.imags.unshift(BASE_URL+t1)
								})
							}
						})
						// console.log(this.msglist)
						this.$forceUpdate()
					}
				})
			},
			clicktab(e){
				this.type=e.type
				
				if(e.short_type){
					this.short_type=e.short_type
				}else{
					this.short_type=''
				}
				
				this.getlist()
			}
		}
	}
</script>

<style lang="scss">
.tab{
	padding: 30rpx 0 20rpx;
}
.popbox{
	width: 480rpx;
	background-color: #fff;
	border-radius: 30rpx;
	padding: 40rpx 30rpx;
	&__title{
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		line-height: 28rpx;
		color: #202020;
		text-align: center;
		padding: 8rpx 0 38rpx;
		&__xing{
			color: #0484FC;
			font-size: 30rpx;
		}
	}
	&__footer{
		padding: 36rpx 34rpx 0;
	}
}
/deep/.u-textarea{
	background-color: #F5F1F1!important;
	border-radius: 30rpx!important;
	padding: 20rpx 30rpx!important;
	font-family: PingFang SC!important;
	font-weight: 500!important;
	font-size: 24rpx!important;
	color:#333!important;
	line-height: 36rpx!important;
	
}
/deep/.u-textarea__field{
	font-family: PingFang SC!important;
	font-weight: 500!important;
	font-size: 24rpx!important;
	color:#333!important;
	line-height: 36rpx!important;
}
</style>
